﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace MainWinform
{
    public partial class MainWin : Form
    {
        public MainWin()
        {
            InitializeComponent();

            TaskPanelNotifyIcon.Visible = true;
            TaskPanelNotifyIcon.MouseDoubleClick += OnPanelIconDoubleClick;
            Resize += OnWinResize;

            //添加对应的消息响应动作
            Program.msg.AddAction(0x8002,ShowSelf);
        }

        protected override void OnResize(EventArgs e)
        {
            base.OnResize(e);
            if(WindowState == FormWindowState.Minimized)
            {
                Console.WriteLine("Hide");
                Hide();
            }
        }

        protected virtual void OnPanelIconDoubleClick(object sender,MouseEventArgs e)
        {
            Show();
            WindowState = FormWindowState.Normal;
            Focus();
        }
        protected virtual void OnWinResize(object sender,EventArgs e)
        {
            Console.WriteLine(e.GetType());
        }

        protected virtual void ShowSelf(Message m)
        {
            Show();
            WindowState = FormWindowState.Normal;
            Focus();
        }
    }
}
